package com.ecoolex.ying.space.job.consumer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.ecoolex.framework.message.queue.Consumer;
import com.ecoolex.framework.message.queue.ConsumerComponent;
import com.ecoolex.framework.message.queue.Message;
import com.ecoolex.ying.space.core.manager.PushMessageReadStateManager;
import com.ecoolex.ying.space.core.manager.UserFavoriteManager;
import com.ecoolex.ying.space.core.manager.UserInfoExtManager;
import com.ecoolex.ying.space.core.manager.UserWatchManager;
import com.ecoolex.ying.space.job.core.JOBConstant;


@ConsumerComponent
public class UserCreateConsumer {

    private Logger log = LoggerFactory.getLogger(UserCreateConsumer.class);

    @Autowired
    private UserInfoExtManager userInfoExtManager;
    
    @Autowired
    private UserWatchManager userWatchManager;
    
    @Autowired
    private UserFavoriteManager userFavoriteManager;

    @Consumer(group = JOBConstant.MODULE_NAME, theme = "user.system.user.create", describe = "用户创建时创建扩展信息")
    public void consumer(Message message) throws Exception {
        int userId = Integer.valueOf(message.getContent());

        userInfoExtManager.create(userId, this.getClass().getSimpleName());
        //关注官方账号
        userWatchManager.addDefaultWatch(userId, this.getClass().getSimpleName());
        //创建默认收藏夹
        userFavoriteManager.addDefault(userId, this.getClass().getSimpleName());
    }
}
